#include <SDL/SDL.h>
int menu(SDL_Surface *screen)
{
    SDL_Rect dct;
    SDL_Event event;

    int done=0;


    // load an image
    SDL_Surface* mp = SDL_LoadBMP("img/1.bmp");


    if (!mp)
    {
        printf("Unable to load bitmap: %s\n", SDL_GetError());
        return 1;
    }
    SDL_Surface *mg = SDL_LoadBMP("img/fleche.bmp");
    if (mg == NULL)
    {
        printf("Unable to load bitmap: %s\n", SDL_GetError());
        return 1;
    }

    // centre the bitmap on screen

    dct.x = 470 ;
    dct.y =  270;

    // program main loop

    SDL_EnableKeyRepeat(1,1);
    SDL_SetColorKey(mg,SDL_SRCCOLORKEY,SDL_MapRGB(mg->format,255,255,255));

    while (!done)
    {
        // message processing loop
        while (SDL_PollEvent(&event))
        {
            // check for messages
            switch (event.type)
            {
                // exit if the window is closed
            case SDL_QUIT:
                done = 1;
                break;

                // check for keypresses
            case SDL_KEYDOWN:
            {
                // exit if ESCAPE is pressed
                switch (event.key.keysym.sym)
                {

                case  SDLK_ESCAPE:
                    done = 1;
                    break;
                case SDLK_UP:
                    if(dct.y==440)
                        dct.y=dct.y-170;

                    break;
                case SDLK_DOWN:
                    if(dct.y==270)
                        dct.y= dct.y+170;
                    break;
                case SDLK_SPACE:
                    if(dct.y==270)
                        return(1);
                    if(dct.y==440)
                        return(0);


                } // end main loop

            }

            }

        }

        SDL_FillRect(screen, 0, SDL_MapRGB(screen->format, 0, 0, 0));
        // draw bitmap
        SDL_BlitSurface(mp, NULL, screen, NULL);
        SDL_BlitSurface(mg, NULL, screen, &dct);
        // DRAWING ENDS HERE
        // finally, update the screen
        SDL_Flip(screen);

    }

    SDL_FreeSurface(mp);
    SDL_FreeSurface(mg);

}
